﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Buccaneer.Properties;
using System.IO;

namespace Buccaneer
{
    public partial class Form1 : Form
    {
        #region buttons

        BitmapButton 
            btn_navigateBack, 
            btn_navigateUp, 
            btn_navigateDown, 
            btn_navigateForward,
            btn_navigateGo,
            btn_close;

        #endregion

        #region tabs

        BitmapButton[] tabs;
        PictureBox[] tabSeparators;
        BitmapButton trytab;

        #endregion

        public Form1()
        {
            InitializeComponent();

            btn_navigateBack = BitmapButtonsInitializer.AddNavigateBack();
            btn_navigateBack.Click += new EventHandler(navigateBack_Click);
            Controls.Add(btn_navigateBack);

            btn_navigateUp = BitmapButtonsInitializer.AddNavigateUp();
            btn_navigateUp.Click += new EventHandler(navigateUp_Click);
            Controls.Add(btn_navigateUp);

            btn_navigateDown = BitmapButtonsInitializer.AddNavigateDown();
            btn_navigateDown.Click += new EventHandler(navigateDown_Click);
            Controls.Add(btn_navigateDown);

            btn_navigateForward = BitmapButtonsInitializer.AddNavigateForward();
            btn_navigateForward.Click += new EventHandler(navigateForward_Click);
            Controls.Add(btn_navigateForward);

            btn_navigateGo = BitmapButtonsInitializer.AddNavigateGo();
            btn_navigateGo.Click += new EventHandler(navigateGo_Click);
            Controls.Add(btn_navigateGo);

            btn_close = BitmapButtonsInitializer.AddClose();
            btn_close.Click += new EventHandler(close_Click);
            Controls.Add(btn_close);

            TabInitializer.AddNewTab("main - explorer");
            //TabInitializer.AddNewTab("main - editor");
            //TabInitializer.AddNewTab("main - new");
            //TabInitializer.AddNewTab("main - text");

            tabs = TabInitializer.UpdateTabs(0);
            tabSeparators = TabInitializer.tabSeparators;

            for (int i = 0; i < tabs.Length; i++)
            {
                Controls.Add(tabs[i]);
            }

            for (int i = 0; i < tabSeparators.Length; i++)
            {
                Controls.Add(tabSeparators[i]);
            }
        }

        private void navigateBack_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Navigating back...");
        }

        private void navigateUp_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Navigating up...");
        }

        private void navigateDown_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Navigating down...");
        }

        private void navigateForward_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Navigating forward...");
        }


        private void navigateGo_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Navigating...");
        }


        private void close_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            // Call the find plugins routine, to search in our Plugins Folder
            Global.Plugins.FindPlugins(Application.StartupPath + @"\Plugins");

            Console.WriteLine("following " + Global.Plugins.AvailablePlugins.Count.ToString() + " plugins found:");

            // Add each plugin to the treeview
            foreach (Types.AvailablePlugin pluginOn in Global.Plugins.AvailablePlugins)
            {
                Console.WriteLine("  - " + pluginOn.Instance.Name);
            }
            //*/
            Types.AvailablePlugin selectedPlugin = Global.Plugins.AvailablePlugins.Find("Explorer");
            if (selectedPlugin != null)
            {
                // Clear visuals: doesn't close the instance of the plugin
                pnl_editPlugin.Controls.Clear();

                // Set the dockstyle of the plugin to fill, to fill up the space provided
                selectedPlugin.Instance.MainInterface.Dock = DockStyle.Fill;

                // Finally, add the usercontrol to the panel
                pnl_editPlugin.Controls.Add(selectedPlugin.Instance.MainInterface);

            }
        }


   }
}
